package com.hdu.suixianglu;

public class lc209 {
    class Solution {
        public int minSubArrayLen(int target, int[] nums) {
            int len = Integer.MAX_VALUE;
            int l = 0, r = 0;
            int curSum = 0;
            while (r < nums.length)
            {
                curSum += nums[r];
                while (curSum >= target)
                {
                    len = Math.min(len, r - l + 1);
                    curSum -= nums[l++];
                }
                r++;
            }
            return len == Integer.MAX_VALUE ? 0 : len;
        }
    }
}
